﻿using NUnit.Framework;
using Present.Commands.Async;
using Present.Commands.Async.Actions;
using Present.Commands.Fluent;
using Rhino.Mocks;

namespace Present.Commands.Tests.Fluent
{
    [TestFixture]
    public class AsyncCommandBuilderTestCase : TestCase
    {
        private IAsyncAction action;
        private AsyncCommandBuilder builder;

        public override void Setup()
        {
            base.Setup();
            action = MockRepository.GenerateStub<IAsyncAction>();
            builder = new AsyncCommandBuilder(action);
        }

        [Test]
        public void ExecuteBuiltCommand()
        {
            var execution = new ActionExecution(null);
            action.Stub(x => x.PrepareWork(null)).Return(execution);
            builder.Execute(null);
            action.AssertWasCalled(x => x.DoWork(execution));
        }

      

        [Test]
        public void CanBeCastToCommand()
        {
            Assert.IsInstanceOf<AsyncCommand>((AsyncCommand)builder);
        }

    }
}
